function hideerrorbox(){
    $(".error-message-box").hide();
}
function showerrorbox(id,msg){
    $(".error-message-box").show();
    $(".error-message-box .id").html(id);
    $(".error-message-box .msg").html(msg);
}
function showgrowl(snotice,smsg){
    $.growlUI(snotice, smsg);
}
function showmsg(smsg,ntimeout){
    $.blockUI({ 
        message: smsg, 
        fadeIn: 700, 
        fadeOut: 700, 
        timeout: ntimeout, 
        showOverlay: false, 
        centerY: false, 
        css: { 
            margin:'0 0 0 -200px',
            width: '400px', 
            top: '0px', 
            left: '50%', 
            right: '10px', 
            border: 'none', 
            padding: '8px 8px 9px 8px', 
            backgroundColor: '#000', 
            '-webkit-border-radius': '0px', 
            '-moz-border-radius': '0px', 
            opacity: .5, 
            color: '#fff' 
        } 
    }); 
}
function loadhtml(url,obj){
    showmsg("Loadding...");
    $("#id-iframe").show();
    $("#id-iframe2").hide();
    if(obj!=null && obj.length)
        obj.load(url,hidemsg);
    else
        $("#id-iframe").load(url,hidemsg);
}
function loadhtmltobox(url,obj){
    showmsg("Loadding...");
    if(obj!=null && obj.length)
        obj.load(url,hidemsg);
    else{
        alert("cant find content box.");
        hidemsg();
    }
}
function hidemsg(){
    $.unblockUI();
}
function changeuploadfolder(folder){
    
    var surl="./Controller/";
        var sdata={
                "AUnit":"loadfolder",
                "folder":folder
        };
        jQuery.ajax({
                type:"POST", 
                data:sdata, 
                dataType:"text", 
                url:surl, 
                success: function (data){ 
                    $("#files").html(data);
                },
                error: function (xhr, ajaxOptions, thrownError){
    
                }
        });
}
function loaditem(id){
    $("#id-iframe").hide();
    $("#id-iframe2").show();
    $("#id-iframe2 div.content").html("Please wait...");
    $("#id-iframe2 div.content").load("./Controller/?AUnit=itemdetail&id="+id);
}
//about script

function loaditemdetail(id){
    showmsg("Loadding...");
    $(".id-item-detail").show();
    $("#"+$(".tab.active").attr("title")).hide();
    if(id==null)
        $(".id-item-detail").load("./Controller/?AUnit=05_detail",function(){
            
            hidemsg();
        });
    else
        //if( $("#txtidi").val()==undefined || $("#txtidi").val()!=id)
        $(".id-item-detail").load("./Controller/?AUnit=05_detail&id="+id,function(){
            
            hidemsg();
            
            
        });
}
function loadproductdetail(id){
    $.blockUI({ 
            message: $('#content_product_detail'), 
            css: { margin:'0px 0 0 -360px',width:'720px',height:'auto',top:'50px',left:'50%',border: '0px solid #ccc' } 
    });
    //showmsg("Loadding...");
    if(id==null)
        $("#content_product_detail div.ui-content").load("./Controller/?AUnit=06_1_product_detail",function(){  
            //hidemsg();
        });
    else
        //if( $("#txtidi").val()==undefined || $("#txtidi").val()!=id)
        $("#content_product_detail div.ui-content").load("./Controller/?AUnit=06_1_product_detail&id="+id,function(){  
            //hidemsg();
        });
}
function HideuiContent(){
    $.unblockUI();
    $("#content_product_detail div.ui-content").html("<div class='loadding'></div>");
}
function hideproductdetail(){
    
    showmsg("Loadding...",1000);
    $("#content_product_detail").hide();
    // slide this content up
    $("#"+$(".tab.active").attr("title")).show();
}

function hideitemdetail(){
    
    showmsg("Loadding...",1000);
    $(".id-item-detail").hide();
    // slide this content up
    $("#"+$(".tab.active").attr("title")).show();
}

//end about script
function newitem(){
    $("#id-iframe").hide();
    $("#id-iframe2").show();
    $("#id-iframe2 div.content").html("Please wait...");
    $("#id-iframe2 div.content").load("./Controller/?AUnit=itemdetail");
}
function hidebox2(){
    $("#id-iframe").show();
    $("#id-iframe2").hide();
}
        
function BrowseServer( startupPath, functionData )
{
	// You can use the "CKFinder" class to render CKFinder in a page:
	var finder = new CKFinder();

	// The path for the installation of CKFinder (default = "/ckfinder/").
	finder.basePath = '../';

	//Startup path in a form: "Type:/path/to/directory/"
	finder.startupPath = startupPath;

	// Name of a function which is called when a file is selected in CKFinder.
	finder.selectActionFunction = SetFileField;

	// Additional data to be passed to the selectActionFunction in a second argument.
	// We'll use this feature to pass the Id of a field that will be updated.
	finder.selectActionData = functionData;

	// Name of a function which is called when a thumbnail is selected in CKFinder.
	finder.selectThumbnailActionFunction = ShowThumbnails;

	// Launch CKFinder
	finder.popup();
}

// This is a sample function which is called when a file is selected in CKFinder.
function SetFileField( fileUrl, data )
{
	document.getElementById( data["selectActionData"] ).value = fileUrl;
}
function ShowThumbnails( fileUrl, data )
{
	// this = CKFinderAPI
	var sFileName = this.getSelectedFile().name;
//	document.getElementById( 'thumbnails' ).innerHTML +=
//			'<div class="thumb">' +
//				'<img src="' + fileUrl + '" />' +
//				'<div class="caption">' +
//					'<a href="' + data["fileUrl"] + '" target="_blank">' + sFileName + '</a> (' + data["fileSize"] + 'KB)' +
//				'</div>' +
//			'</div>';
//
//	document.getElementById( 'preview' ).style.display = "";
	// It is not required to return any value.
	// When false is returned, CKFinder will not close automatically.
	return false;
}